import http from "@/utils/request";

const apiPrefix = "/type";


export async function addType(data) {
    return await http.request({
        data: data,
        url: apiPrefix,
        method: 'post'
    })
}

export async function deleteTypeById(id){
    return await http.request({
        params: {
            id
        },
        url: apiPrefix+'/id',
        method: 'delete'
    })
}

export async function deleteTypeByIds(ids){
    return await http.request({
        params: {
            ids
        },
        url: apiPrefix+'/batch',
        method: 'delete'
    })
}


export async function searchTypeById(id){
    return await http.request({
        params: {
            id
        },
        url: apiPrefix+'/id',
        method: 'get'
    })
}

export async function searchType(params){
  return await http.request({
    params: params,
    url: apiPrefix,
    method: 'get'
  })
}
export async function searchTypeAsTree(){
  return await http.request({
    url: apiPrefix+'/tree',
    method: 'get'
  })
}

export async function searchTypeByPage(params){
    return await http.request({
        params: params,
        url: apiPrefix+'/page',
        method: 'get'
    })
}


export async function updateTypeById(data){
  return await http.request({
    data: data,
    url: apiPrefix,
    method: 'put'
  })
}
export async function updateTypeOrderByIds(data){
  return await http.request({
    data: data,
    url: apiPrefix+'/order',
    method: 'post'
  })
}
